package com.wica.adapter;

import com.wica.view.ELSearch;

import android.app.Dialog;
import android.content.Context;
import android.preference.PreferenceManager;

public class ELASearch extends EfficientListAdapter {

	// *************** Constants ************** //
    public static final String TAB_PREFERENCES_SEARCH_1 = "numberOfResults_search_preference";
    public static final String TAB_PREFERENCES_SEARCH_2= "numberOfResults_search_preference";
    // Set up a random unique ID for message handler
    protected static final int GUIUPDATEIDENTIFIER = 12345;

	// *************** Attributes ************************* //
	/* Attributes: (regarding FaceTube WebService) */
    /** numberOfResults: Integer -- 0..30 (regarding FaceTube WebService)**/
	private Integer numberOfResults;
	/** searchString: String	**/
	private String searchString;
	/** orderBy: Integer			-- by relevance "ORDER_BY_RELEVANCE = 11"
	 * 								-- by viewcount "ORDER_BY_VIEWCOUNT = 12"
	 * 								-- by rating 	"ORDER_BY_RATING	= 13"
	 **/
	private Integer orderBy;
	/** userID: Integer	**/
	private Integer userID;

	public Dialog dialog;
	
	public ELASearch(ELSearch list,String searchString, Integer orderBy) {
		super(list);	
		this.list=list;
		this.adapter=this;
		this.numberOfResults=Integer.valueOf(PreferenceManager.getDefaultSharedPreferences((Context)list).getString("numberOfResults_search_preference", "30"));
		this.searchString=searchString;
		this.orderBy=orderBy;
        this.userID=PreferenceManager.getDefaultSharedPreferences((Context)list).getInt("userID", -1);
		if (!internetNetworkAvailable())
			this.searchString="__empty";
        getListOfVideosThread();		
	}//EfficientListAdapterMostViewed method	
    
	@Override
    protected void getListOfVideosMethod() {
    	super.getListOfVideosMethod();
		listOfMovies = fts.getRandomSearchClips(searchString,numberOfResults, orderBy.intValue(), userID);
	}// getListOfVideosMethod method
    
    // *************** Set methods ************** //  
	public void setNumberOfResults(Integer numberOfResults){
    	this.numberOfResults = numberOfResults;
    }// setNumberOfResults method    

    // *************** Get methods ************** //  
	public Integer getNumberOfResults(){
    	return(numberOfResults);
    }// getNumberOfResults method
	
}// ELASearch class
